country_decisions = {

	spanish_nation = {
		major = yes
		potential = {
			normal_or_historical_nations = yes
			OR = {
				ai = no
				is_playing_custom_nation = no
			}
			NOT = { tag = SPA }
			NOT = { tag = PAP }
			NOT = { tag = HLR }
			NOT = { tag = FRA }		# Basque is a valid culture for both FRA and SPA
			NOT = { tag = KNI }		# Maltese is part of iberian culture group
			NOT = { tag = GRA }
			NOT = { tag = ADU }
			NOT = { tag = CRD }
			NOT = { tag = EUR }	
			OR = {
				ai = no
				ARA = { ai = no }
				AND = {
					NOT = { tag = ARA }
					NOT = { tag = CAS }
				}
				is_year = 1500
			}
			OR = {
				ai = no
				AND = {
					ai = yes
					num_of_cities = 3
					NOT = { exists = SPA }
				}
			}
			OR = {
				ai = no
				AND = {
					ai = yes
					NOT = { tag = POR }
				}
			}
			OR = {
				culture_group = iberian
				primary_culture = basque
			}
			is_colonial_nation = no
			OR = {
				is_former_colonial_nation = no
				AND = {
					is_former_colonial_nation = yes
					ai = no
				}
			}
		}
		allow = {
			NOT = { exists = SPA }
			adm_tech = 10
			is_subject = no
			is_nomad = no
			is_at_war = no
			owns_core_province = 213	# Barcelona
			owns_core_province = 214	# Aragn
			owns_core_province = 215	# Castilla La Vieja
			owns_core_province = 216	# Salamanca
			owns_core_province = 224	# Andalucia
			owns_core_province = 219	# Toledo
			owns_core_province = 220	# Valencia
			owns_core_province = 223	# Granada
			NOT = {
				iberia_region = {
					owned_by = GRA
				}
			}
		}
		effect = {
			change_tag = SPA
			if = {
				limit = {
					is_part_of_hre = yes
					NOT = { has_country_modifier = european_union }
					is_elector = no
				}
				every_owned_province = {
					limit = {
						is_part_of_hre = yes
					}
					set_in_empire = no
				}
			}
			if = {
				limit = { NOT = { government_rank = 2 } }
				set_government_rank = 2
			}
			custom_tooltip = spanish_unification_effect.tooltip
			hidden_effect = {
				iberia_region = {
					limit = {
						NOT = { area = macaronesia_area }
						NOT = { area = alentejo_area }
						NOT = { area = beieras_area }
					}
					add_permanent_claim = SPA
				}
			}
			add_country_modifier = {
				name = "centralization_modifier"
				duration = 7300
			}
			add_prestige = 25
		}
		ai_will_do = {
			factor = 1
		}
		ai_importance = 400
	}
	
	spanish_nation_diplomatically = {
		major = yes
		potential = {
			normal_or_historical_nations = yes
			OR = {
				ai = no
				is_playing_custom_nation = no
			}
			is_tutorial_active = no
			tag = CAS
			owns = 219
			OR = {
				ai = no
				AND = {
					ai = yes
					OR = {
						ARA = {	junior_union_with = CAS	}
						ARA = {	vassal_of = CAS	}
					}
				}
			}
		}
		allow = {
			adm_tech = 10
			is_subject = no
			is_nomad = no
			is_at_war = no
			legitimacy = 100
			NOT = {
				iberia_region = {
					owned_by = GRA
				}
			}
			OR = {
				ARA = {	junior_union_with = CAS	}
				ARA = {	vassal_of = CAS	}
			}
			ARA = {
				NOT = { num_of_cities = 32 } #Original 17 +15
			}
		}
		effect = {
			change_tag = SPA
			if = {
				limit = {
					is_part_of_hre = yes
					NOT = { has_country_modifier = european_union }
					is_elector = no
				}
				every_owned_province = {
					limit = {
						is_part_of_hre = yes
					}
					set_in_empire = no
				}
			}
			if = {
				limit = { NOT = { government_rank = 2 } }
				set_government_rank = 2
			}
			if = {
				limit = {
					ARA = {
						ai = yes
					}
				}
				inherit = ARA
			}	
			if = {
				limit = {
					has_custom_ideas = no
					OR = {
						ai = no
						AND = {
							ai = yes
							has_idea_group = default_ideas
						}
					}
				}
				country_event = { id = ideagroups.1 } #Swap Ideas
			}
			custom_tooltip = spanish_unification_effect.tooltip
			hidden_effect = {
				iberia_region = {
					limit = {
						NOT = { area = macaronesia_area }
						NOT = { area = alentejo_area }
						NOT = { area = beieras_area }
					}
					add_permanent_claim = SPA
				}
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				religion_group = muslim
			}
		}
		ai_importance = 200
	}	
	
}
